package com.xbongbong.pro.enums.menu.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.MenuTypeEnum;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

/**
 * 费用管理枚举类
 * 创建时间 2020/3/17 5:18 PM
 * 修改时间 2020/3/17 5:18 PM
 * @author chy
 */
@Getter
public enum ExpenseManagementMenuEnum {

    /**
     * 每刻报销枚举类
     */
    // 报销单
    REIMBURSEMENT_FORM("enum.expenseManagementMenu.name.reimbursement_form", XbbRefTypeEnum.REIMBURSEMENT_FORM.getAlias(), XbbRefTypeEnum.REIMBURSEMENT_FORM.getCode(),
            AccessLinkEnum.REIMBURSEMENT_FORM,
            XbbRefTypeEnum.REIMBURSEMENT_FORM.getAlias(), MenuTypeEnum.FORM.getType(), XbbRefTypeEnum.EXPENSE_MANAGEMENT.getAlias()),

    EXPENSE("enum.expenseManagementMenu.name.expense", XbbRefTypeEnum.EXPENSE.getAlias(), XbbRefTypeEnum.EXPENSE.getCode(),
            AccessLinkEnum.EXPENSE,
            XbbRefTypeEnum.EXPENSE.getAlias(), MenuTypeEnum.FORM.getType(), XbbRefTypeEnum.EXPENSE_MANAGEMENT.getAlias()),
    ;

    /**
     * saas应用标示解释
     */
    private String name;
    /**
     * saas应用标示
     *
     * @see XbbRefTypeEnum
     */
    private String alias;
    /**
     * @see XbbRefTypeEnum
     */
    private Integer code;
    /**
     * 对应的链接
     */
    private AccessLinkEnum accessLinkEnum;

    /**
     * 父节点，如果没有父节点，则此值为空字符串
     */
    private String parent;

    /**
     * 类型
     *
     * @see MenuTypeEnum
     */
    private Integer type;

    /**
     * 所属crm或者进销存的业务类型
     * 资金管理中的回款管理和发票管理crm开启才显示，库存管理则随进销存的显示而显示；并且资金管理也可以作为应用参与排序
     */
    private String belongAlias;


    ExpenseManagementMenuEnum(String name, String alias, Integer code, AccessLinkEnum accessLinkEnum, String parent, Integer type, String belongAlias) {
        this.name = name;
        this.alias = alias;
        this.code = code;
        this.accessLinkEnum = accessLinkEnum;
        this.parent = parent;
        this.type = type;
        this.belongAlias = belongAlias;
    }

    public static ExpenseManagementMenuEnum getByAlias(String alias) {
        for (ExpenseManagementMenuEnum fundManagementMenuEnum : values()) {
            if (fundManagementMenuEnum.getAlias().equals(alias)) {
                return fundManagementMenuEnum;
            }
        }
        return null;
    }

    public static ExpenseManagementMenuEnum getByCode(Integer code) {
        for (ExpenseManagementMenuEnum fundManagementMenuEnum : values()) {
            if (fundManagementMenuEnum.getCode().equals(code)) {
                return fundManagementMenuEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
